<div>
    <ol class="breadcrumb" >
        <li> <i class="fa fa-anchor"></i>
            &nbsp;消费管理
        </li>
        <li>消费列表</li>
    </ol>
    <ul class="nav nav-tabs" role="tablist">

        <if condition="$_GET['tab'] eq 1">
            <li role="presentation" >
                <a href="#home" onclick="window.location.href='__URL__/index'" aria-controls="home" role="tab" data-toggle="tab">按会员卡</a>
            </li>

            <li role="presentation" class="active">
                <a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">按电桩</a>
            </li>
        <else />
            <li role="presentation" class="active">
                <a href="#home" aria-controls="home" role="tab" data-toggle="tab">按会员卡</a>
            </li>

            <li role="presentation">
                <a href="#profile" onclick="window.location.href='__URL__/index/tab/1'" aria-controls="profile" role="tab" data-toggle="tab">按电桩</a>
            </li>
        </if>

    </ul>
    <div class="tab-content">
        <if condition="$_GET['tab'] eq 1">
            <div role="tabpanel" class="tab-pane" id="home">
        <else />
            <div role="tabpanel" class="tab-pane active" id="home">
        </if>
            <div class="panel">
                <div class="panel-heading" >
                    <i class="fa fa-list"></i>
                    &nbsp;&nbsp;消费记录表
                </div>
                <form class="search-form" action={:U("Bill/index")} method="get">
                    <div class="panel-body search-panel-body retract">
                        <div class="col-xs-8 search-col">
                            <div class="input-group">
                                <span class="input-group-addon">时间段</span>
                                <input type="text" class="form-control required form_month" placeholder="开始日期" name="start_time" value="{$_GET['start_time']}"  data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                                <span class="input-group-addon">~~</span>
                                <input type="text" class="form-control required form_month" placeholder="截止日期" value="{$_GET['end_time']}" name="end_time"  data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                                <span class="input-group-addon">卡号</span>
                                <input type="text" name="user_pay_card" maxlength="20" class="form-control" value="{$_GET['user_pay_card']}" placeholder="会员卡号"></div>
                        </div>
                        <div class="col-xs-2 search-col">
                            <button  type="submit" class="btn btn-warning">
                                <i class="fa fa-search"></i>
                                &nbsp;搜索
                            </button>
                        </div>
                    </div>
                </form>
                <table  class="table table-bordered table-striped table-mcit" >
                    <thead>
                    <tr>
                        <th >
                            <button class='btn btn-block btn-mcit' type='button' >ID</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >会员卡号</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >充电时长(小时)</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >充电电量(度)</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >消费金额</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >充电地点</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >站点名称</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='submit' >操作</button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="DataTableContent">
                    <empty name="pay">
                        <td colspan="99" style="text-align:center" class="danger"> <strong><i class="fa fa-meh-o"></i>
                            &nbsp;&nbsp;当前条件下没有数据</strong>
                        </td>
                        <else />
                        <volist name="pay" id="data">
                            <tr>
                                <td>{$data.id}</td>
                                <td>{$data.user_pay_card}</td>
                                <td>{$data.time_num}</td>
                                <td>{$data.this_reading}</td>
                                <td>&yen;&nbsp;&nbsp;{$data.this_amount}</td>
                                <td>{$data.location_text}</td>
                                <td><span title="{$data.plant_text}">{$data.plant_name}</span></td>
                                <td>
                                    <a class="btn btn-success btn-sm" href="__URL__/detail/id/{$data.id}">
                                        <i class="fa fa-eye"></i>
                                        &nbsp;详情
                                    </a>
                                    <!--<if condition="$_SESSION['role'] eq 805 || $_SESSION['role'] eq 802">
                                        <a class="btn btn-sm btn-danger deleteBtn" href="#confirmDelete" data-target="#confirmDelete" data-toggle="modal" data-id='{$data.id}'><i class="fa fa-trash-o"></i>
                                            &nbsp;删除</a>
                                        <else /></if>-->
                                </td>
                            </tr>
                        </volist>
                    </empty>
                    <tr>
                        <td colspan="99" style="text-align:center">
                            <ul class="pagination">{$pageView}</ul>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <if condition="$_GET['tab'] eq 1">
            <div role="tabpanel" class="tab-pane active" id="profile">
        <else />
                <div role="tabpanel" class="tab-pane" id="profile">
        </if>
            <div class="panel">
                <div class="panel-heading" >
                    <i class="fa fa-list"></i>
                    &nbsp;&nbsp;消费记录表
                </div>
                <form class="search-form" action={:U("Bill/index")} method="get">
                    <div class="panel-body search-panel-body retract"  >
                        <div class="col-xs-8 search-col">
                            <div class="input-group">
                                <input type="hidden" name="tab" value="1"/>
                                <span class="input-group-addon">时间段</span>
                                <input type="text" class="form-control required form_month" placeholder="开始日期" name="start_time" value="{$_GET['start_time']}"  data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                                <span class="input-group-addon">~~</span>
                                <input type="text" class="form-control required form_month" placeholder="截止日期" value="{$_GET['end_time']}" name="end_time"  data-date-format="yyyy-mm-dd" data-link-format="yyyy-mm-dd">
                                <span class="input-group-addon">设备地址</span>
                                <input type="text" name="key_link" maxlength="20" class="form-control" value="{$_GET['key_link']}" placeholder="设备地址"></div>
                        </div>
                        <div class="col-xs-2 search-col">
                            <button  type="submit" class="btn btn-warning">
                                <i class="fa fa-search"></i>
                                &nbsp;搜索
                            </button>
                        </div>
                    </div>
                </form>
                <table  class="table table-bordered table-striped table-mcit" >
                    <thead>
                    <tr>
                        <th >
                            <button class='btn btn-block btn-mcit' type='button' >ID</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >设备地址</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >充电时长(小时)</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >充电电量(度)</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >消费金额</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >充电地点</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='button' >站点名称</button>
                        </th>
                        <th>
                            <button class='btn btn-block btn-mcit' type='submit' >操作</button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="DataTableContent1">
                    <empty name="pay">
                        <td colspan="99" style="text-align:center" class="danger"> <strong><i class="fa fa-meh-o"></i>
                            &nbsp;&nbsp;当前条件下没有数据</strong>
                        </td>
                        <else />
                        <volist name="pay" id="data">
                            <tr>
                                <td>{$data.id}</td>
                                <td>{$data.key_link}</td>
                                <td>{$data.time_num}</td>
                                <td>{$data.this_reading}</td>
                                <td>&yen;&nbsp;&nbsp;{$data.this_amount}</td>
                                <td>{$data.location_text}</td>
                                <td><span title="{$data.plant_text}">{$data.plant_name}</span></td>
                                <td>
                                    <a class="btn btn-success btn-sm" href="__URL__/detail/id/{$data.id}">
                                        <i class="fa fa-eye"></i>
                                        &nbsp;详情
                                    </a>
                                    <!--<if condition="$_SESSION['role'] eq 805 || $_SESSION['role'] eq 802">
                                        <a class="btn btn-sm btn-danger deleteBtn" href="#confirmDelete" data-target="#confirmDelete" data-toggle="modal" data-id='{$data.id}'><i class="fa fa-trash-o"></i>
                                            &nbsp;删除</a>
                                        <else /></if>-->
                                </td>
                            </tr>
                        </volist>
                    </empty>
                    <tr>
                        <td colspan="99" style="text-align:center">
                            <ul class="pagination">{$pageView}</ul>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>


</div>
<!-- 删除分类 -->
<div id="confirmDelete" class="modal  fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 id="myModalLabel">是否确认删除当前记录？</h4>
            </div>
            <div class="modal-body" style="color: #D2322D">
                注意！删除后将不可恢复，<b class="alert-danger">请谨慎操作</b>。
            </div>
            <div class="modal-footer">
                <a class="btn" data-dismiss="modal" aria-hidden="true" id="modelClose">关闭</a>
                <a class="btn btn-primary" id="confirmDeleteBtn">确定</a>
            </div>
        </div></div>
    <div class="hide" id="cache">1</div>
</div>
<import file="js.jquery#chained" />
<import type='css' file="css.datetimepicker" />
<import file="js.bootstrap-datetimepicker#min" />
<import file="js.bootstrap-datetimepicker#zh-CN" />
<import file="js.maskedinput" />
<script type="text/javascript">
    $(document).ready(function () {
        $("#location-s").chained("#location-f");
        $("#location-t").chained("#location-s");
        $(".form_month").datetimepicker({
            language: 'zh-CN',
            autoclose: true,
            startView:'month',
            minView: 'month',
            todayBtn: true,
            viewSelect: 'year',
            pickerPosition: "bottom-left"
        });
        $(".deleteBtn").click(function (){
            var id = $(this).attr("data-id");
            $("#cache").val(id);
        });
        $("#confirmDeleteBtn").click(function (){
            var id = $("#cache").val();
            //alert(id);
            $.ajax({
                type:"post",
                url:'__URL__/delBill',
                data:'id='+id,
                success:function(data){
                    if(data == 1){
                        alertify.success("删除成功！");
                    }else{
                        alertify.error("删除失败，请重新提交！");
                    }
                    location.reload();
                }
            });
        });
    });
</script>